package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	UserName string `gorm:"type:varchar(20);not null"`
	Mobile   string `gorm:"type:varchar(11);not null"`
}

type Goods struct {
	gorm.Model
	Name      string  `gorm:"type:varchar(30);not null"`
	Price     float64 `gorm:"type:decimal(10,2);not null"`
	Image     string  `gorm:"type:varchar(255);not null"`
	Inventory int     `gorm:"type:int;not null"` //库存
	Status    int     `gorm:"type:int;not null"` //支付状态
	Method    int     `gorm:"type:int;not null"` //支付方式
}

type Cart struct {
	gorm.Model
	UserId   int `gorm:"type:int;not null"`
	GoodsId  int `gorm:"type:int;not null"`
	Quantity int `gorm:"type:int;not null"`
}

func (g *Goods) GoodsAdd() error {
	return DB.Create(g).Error
}
